<template>
	<view class="u-padding-20">
		<view style="color:#0c838b;" class="u-padding-bottom-20">*反馈内容</view>
		<view class="price_con u-rela" v-if="type==0">
			<text>识别码</text>
			<input v-model="code" class="va_m dis_inl_blo" style="margin-left:20rpx;" type="text">
			<u-icon class="u-abso pos_right" name="scan" color="#ff5500" size="58" @click="scanCode"></u-icon>
		</view>
		<view class="price_intro u-margin-top-30">
			<textarea v-model="memo" value="" placeholder="请将维修完成的报修项目全方位拍照上传，并写文字说明~" />
		</view>
		<view class="uni-flex-center">
			<view class="main-service uni-cell-90">
				<view class="user-list">
					<view style="padding-bottom: 10rpx;">
						<view style="margin-top: 20rpx;">
							<view class="u-padding-bottom-20">上传图片</view>
							<u-upload :action="action" @on-success="successimg" @on-remove="deletePic" :file-list="fileList" maxCount="9"></u-upload>
						</view>
					</view>
				</view>
			</view>
		</view>
		<button class="u-margin-bottom-80 btn_con" @click="completeRepair">标记完成</button>
		<!-- 弹框提示 -->
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import {
		completeRepair
	} from "@/service/repairService.js";
	export default {
		data () {
			return {
				id:0,
				type:0,
				code:'',
				memo:'',
				images:[],
				fileList:[],
				action:'https://admin.gslhzhwy.com/api/upload/file'
			}
		},
		onLoad(options) {
			// console.log(options);
			this.id=options.id;
			this.type=options.type;
		},
		methods:{
			scanCode:function(){
				var that=this;
				uni.scanCode({
					success(res) {
						that.code=res.result;
					}
				})
			},
			successimg:function(e){
				if (e.code == 1) {
					this.images.push(e.data.url);
				}
			},
			// 删除图片
			deletePic(event) {
				this.images.splice(event.index,1);
			},
			completeRepair:function(){
				completeRepair({
					id: this.id,
					code:this.code,
					memo:this.memo,
					image:this.images
				}).then(res=>{
					if(res.code==200){
						this.$refs.uToast.show({
							type: 'success',
							title: '报修完成已提交！',
							icon:false
						})
						setTimeout(function(){
							uni.navigateBack({
								delta:2
							})
						},2000)
					}else{
						this.$refs.uToast.show({
							type: 'error',
							title: res.msg,
							icon:false
						})
					}
					
				})
			},
			
		}
	}
</script>

<style lang="scss">
	.price_con{
		height:70rpx;
		line-height: 70rpx;
		border-bottom:1rpx solid #ddd;
	}
	.price_con input{
		width:200rpx;
		padding:0 10rpx;
		text-align: center;
		border-radius: 10rpx;
		font-size: 26rpx;
		border:1rpx solid #ddd;
	}
	.price_intro textarea{
		width:93%;
		height:150rpx;
		padding:20rpx;
		border-radius: 10rpx;
		font-size: 26rpx;
		// border:1rpx solid #ddd;
	}
	.btn_con{
		height:70rpx;
		line-height: 70rpx;
		font-size: 30rpx;
		border-radius: 35rpx;
		background-image: url('https://resourse.cnlhjt.com/upload/20220825/d1aa35c1d129137d9b12c8f34e59c5bc.png');
		background-size: 100% 70rpx;
		color:#fff;
		margin-top:150rpx;
	}
</style>
